package com.cardone.platform.usercenter.function;

import com.cardone.context.function.Execution0Function;
import com.cardone.platform.usercenter.dto.UserDto;
import com.cardone.platform.usercenter.util.UserUtils;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * Created by c100000002 on 15-1-26.
 */
public class GetUserMapFunction implements Execution0Function<Map<String, String>> {
    @Override
    public Map<String, String> execution() {
        UserDto user = UserUtils.find();

        if (StringUtils.isBlank(user.getId())) {
            return null;
        }

        Map<String, String> userMap = Maps.newHashMap();

        userMap.put("userId", user.getId());
        userMap.put("userCode", user.getCode());
        userMap.put("userName", user.getName());

        return userMap;
    }
}
